package com.goblin.model.media.po;

import com.goblin.model.base.BaseEntity;
import com.goblin.model.uaa.po.User;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

@Data
@Table(name = "t_test_meida_message")
@Entity
public class Message extends BaseEntity {

    private static final long serialVersionUID = -706125120332680376L;

    @Column(name = "content", columnDefinition = "text(1000) COMMENT '消息内容'")
    private String content;

    @Column(name = "receive", columnDefinition = "tinyint(1) COMMENT '消息接收标志 1已接收 0未接收'")
    private Boolean receive;

    @Column(name = "date", columnDefinition = "datetime COMMENT '发送时间戳'")
    private Date date;

    @Column(name = "type", columnDefinition = "int(1) COMMENT '消息类型 1文本 2图片 3语音 4视频 10上线消息 11上线消息反馈 12下綫消息 13发起聊天消息'")
    private Integer type;

    @Column(name = "style", columnDefinition = "text(255) COMMENT '标签修饰'")
    private String style;

    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.DETACH) //JPA注释： 一对一 关系
    @JoinColumn(name = "user_from", referencedColumnName = "id", nullable = false, columnDefinition = " int(11) COMMENT '发送人'")
    private User userFrom;

    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.DETACH) //JPA注释： 一对一 关系
    @JoinColumn(name = "user_to", referencedColumnName = "id", nullable = false, columnDefinition = " int(11) COMMENT '接收人'")
    private User userTo;

    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.DETACH) //JPA注释： 一对一 关系
    @JoinColumn(name = "chat_id", referencedColumnName = "id", nullable = false, columnDefinition = " int(11) COMMENT '聊天id'")
    private Chat chat;
}
